﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Datenanalyse
{
    class folder
    {
        // Object to store the current state, for passing to the caller.
        public class CurrentState
        {
            public int LinesCounted;
            public int WordsMatched;
            public DateTime time_creation;
            public DateTime time_last_access;
            public DateTime time_last_write;
        }

        public string SourceDir;
        private int WordCount;
        private int LinesCounted;

        private void DateiInfo(System.ComponentModel.BackgroundWorker worker,System.ComponentModel.DoWorkEventArgs e)
        {
            // Initialize the variables.
            CurrentState state = new CurrentState();
            
            int elapsedTime = 20;
            DateTime lastReportDateTime = DateTime.Now;
            DateTime DateNow = DateTime.Now;
            DateTime Date6M = DateNow.AddDays(-180);
            DateTime Date1Y = DateNow.AddYears(-1);
            DateTime Date2Y = DateNow.AddYears(-2);
            DateTime Date4Y = DateNow.AddYears(-4);
            DateTime Date8Y = DateNow.AddYears(-8);
            DateTime Date12Y = DateNow.AddYears(-12);
            
                // 1. Für alle Dateien im aktuellen Verzeichnis
            foreach (String strFile in Directory.GetFiles(SourceDir))
                {
                    // 1a. Statt Console.WriteLine hier die gewünschte Aktion
                    //Console.WriteLine(strFile);
                    FileInfo info = new FileInfo(strFile);
                    FileAttributes attributes = info.Attributes;
                    float value = (info.Length) / 1024;
                    DateTime time = info.CreationTime;
                    DateTime time1 = info.LastAccessTime;
                    DateTime time2 = info.LastWriteTime;
                    

                }

                // 2. Für alle Unterverzeichnisse im aktuellen Verzeichnis
                foreach (String strSubDir in Directory.GetDirectories(strDir))
                {
                    // 2a. Statt Console.WriteLine hier die gewünschte Aktion
                    //Console.WriteLine(strSubDir);
                    /*
                    FileInfo info = new FileInfo(strSubDir);
                    FileAttributes attributes = info.Attributes;
                    tbOutPut.Text = tbOutPut.Text + "" + strSubDir + "\r\n";

                    DirectorySecurity ds = Directory.GetAccessControl(strSubDir);
                    AuthorizationRuleCollection arc = ds.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));
                    foreach (FileSystemAccessRule fsar in arc)
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("Identity : " + fsar.IdentityReference.Value);
                        sb.AppendLine("AccessControlType : " + fsar.AccessControlType);
                        sb.AppendLine("FileSystemRights : " + fsar.FileSystemRights);
                        sb.AppendLine("Inherited : " + fsar.IsInherited);
                        sb.AppendLine("PropagationFlags : " + fsar.PropagationFlags);
                        sb.AppendLine("InheritanceFlags : " + fsar.InheritanceFlags);

                        //MessageBox.Show(sb.ToString());
                    }
                    */

                    // 2b. Rekursiver Abstieg
                    DateiInfo(strSubDir);
                }
            
        }
    }
}
